<?php
/**
 +----------------------------------------------------------------------------------------------------
 * 共用核心类; 
 * 
 * # 该文件中初始化了所有基本操作,脚本运行环境、用户输入信息安全过滤等初始化;
 * 
 * 实现1.用户信息初始化
 * 
 +----------------------------------------------------------------------------------------------------
 */
if ( !defined( 'APP_NAME' ) ) {
	exit( 'Access Denied' ) ;
}

class Core {

	public $User = null ;

	static public function &instance() {
		static $object = null ;
		if ( is_null( $object ) ) {
			$object = new Core() ;
		}
		return $object ;
	}

	private function __construct() {
		$this->_init_user() ;
		$this->_init_session() ;
	}

	private function _init_user() {
		# 应将各种句柄送给Director  但此时各句柄尚未封装
		if ( $user = Director::Instance( '', 'Session', 'Get') ) {
		} elseif ( $userinfo = Director::Instance( '', 'Cookie', 'Get') ) {
			$user = Director::Instance( $userinfo, 'Session', 'Set', 'Array' ) ;
		} else {
			$user = Director::Instance( '', 'Session', 'Set', 'Array' ) ;
		}
		$this->User = $user ;
		unset( $user ) ;
	}

	private function _init_session() {
		Session::_init() ;
		Session::start() ;
	}
}